<?php

class Restaurant extends CI_Controller {
    
    function Restaurant() {
        parent::__construct();
    }
    
    public function carte($language_id) {
        $this->load->model('Language_model');
        $language = $this->Language_model->language_get($language_id);
        $data['menu'] = $language['name'];
        
        $this->load->model('Menu_model');
        $this->load->model('Content_model');
        $data['menus'] = $this->Menu_model->menu_language_root_list($language_id);
        if(!empty($data['menus'])) {
            foreach($data['menus'] as $menuKey => $menu) {
                $data['menus'][$menuKey]['submenus'] = $this->Menu_model->sub_menu_list($menu['menu_id']);
                $data['menus'][$menuKey]['content'] = array();
                
                if(!empty($data['menus'][$menuKey]['submenus'])) {
                    foreach($data['menus'][$menuKey]['submenus'] as $submenuKey => $submenu) {
                        $data['menus'][$menuKey]['submenus'][$submenuKey]['prices'] = $this->Menu_model->sub_menu_list($submenu['menu_id']);
                    }
                } else {
                    $menu_content = $this->Content_model->content_menu_get($data['menus'][$menuKey]['menu_id'], $language_id);
                    $data['menus'][$menuKey]['content'] = $menu_content['content'];
                }
            }
        }
        
        $this->load->view('restaurant_customization/index_view', $data);
    }
    
}
?>
